class HexDataParser:
    @staticmethod
    def hex_to_chinese(hex_string):
        bytes_object = bytes.fromhex(hex_string)
        chinese_string = bytes_object.decode("utf-8")
        return chinese_string

    @staticmethod
    def extract_hex_data(hex_string, start_line, start_position, length):
        bytes_per_line = 16
        start_idx = start_line * bytes_per_line * 2 + start_position * 2
        if start_idx + length * 2 > len(hex_string):
            return "Invalid range or insufficient data"
        hex_data = hex_string[start_idx:start_idx + length * 2]
        return hex_data

    @staticmethod
    def hex_to_decimal_array(hex_string):
        return [int(hex_string[i:i+2], 16) for i in range(0, len(hex_string), 2)]

    @staticmethod
    def sfp_convert_to_length(value):
        if value[2] in (0x21, 0x22):
            return "{} m".format(value[18])
        conversion = [(14, "km"), (15, "m"), (16, "50um"), (17, "62.5um"), (18, "50um"), (19, "50um")]
        for byte, unit in conversion:
            if value[byte] > 0:
                return "{} {}".format(value[byte], unit)
        return 'UNKNOWN'

    @staticmethod
    def sfp_convert_to_rate(value):
        byt = value[0]
        d = byt * 100
        if d > 1000:
            return "{} Gbps".format(byt * 100 / 1000)
        return "{} Mbps".format(byt * 100)

    @staticmethod
    def sfp_convert_to_wavelength(value):
        high_byte, low_byte = value
        wavelength = int(f"{high_byte:02x}{low_byte:02x}", 16)
        return "{} nm".format(wavelength)

    @staticmethod
    def parse_binary_data(data):
        first_two_chars = data[:2]
        serial_number = HexDataParser.hex_to_chinese(HexDataParser.extract_hex_data(data, 4, 4, 16))
        manufacturer = HexDataParser.hex_to_chinese(HexDataParser.extract_hex_data(data, 1, 4, 16))
        model = HexDataParser.hex_to_chinese(HexDataParser.extract_hex_data(data, 2, 8, 16))
        date = HexDataParser.hex_to_chinese(HexDataParser.extract_hex_data(data, 5, 4, 8))
        if first_two_chars in ('03', '0B', '06', '0D', '1E', '11', '18', '19'):
            wavelength_value = HexDataParser.hex_to_decimal_array(HexDataParser.extract_hex_data(data, 3, 12, 2))
            rate_value = HexDataParser.hex_to_decimal_array(HexDataParser.extract_hex_data(data, 0, 12, 1))
            distance_value = HexDataParser.hex_to_decimal_array(HexDataParser.extract_hex_data(data, 0, 0, 128))
            wavelength = HexDataParser.sfp_convert_to_wavelength(wavelength_value)
            rate = HexDataParser.sfp_convert_to_rate(rate_value)
            distance = HexDataParser.sfp_convert_to_length(distance_value)
        else:
            wavelength = rate = distance = 'UNKNOWN'

        return {
            "serial_number": serial_number.strip(),
            "manufacturer": manufacturer.strip(),
            "model": model.strip(),
            "date": date.strip(),
            "wavelength": wavelength,
            "rate": rate,
            "distance": distance
        }

# Now, in other parts of your application, you can use it like this:
# parser = HexDataParser()
# parsed_data = parser.parse_binary_data("03042100000000000400000067000000000001004653202020202020202020202020202000649D99512D345350433031202020202020202041202020000000210012000047323431303039373533362D3220202032343033313320200000008A3734302D3033383135322052455620303120200000000000000000002020202000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
# print(parsed_data)
